<template>
    <view>
        <block v-if="isAdmin">
            <cmpt-comm-list
                type="admin_log_list"
                :search="search"
                :_menus="sortMenus"
                :_items="sortItems"
                sortMenusDefaultIndex="0"
                route="admin/log_list"
                topBottom="50"
                placeholder="搜索标题，IP地址"
                @list="bindCommListCmpt"
            >
                <!-- List Begin -->
                <view class="admin-comm-list">
                    <view v-if="dataList && dataList.total" class="load text-black">共有{{ dataList.total }}条符合条件记录</view>

                    <view class="item" v-for="(item, index) in dataList.list" :key="index">
                        <view class="header">
                            <view class="left text-cut">{{ item.LOG_TYPE_DESC }}操作</view>
                            <view class="right"></view>
                        </view>

                        <view class="info">
                            <view class="info-item">
                                <view class="title">操作人</view>
                                <view class="mao">：</view>
                                <view class="content">{{ item.LOG_ADMIN_NAME }}</view>
                            </view>
                            <view class="info-item">
                                <view class="title">操作时间</view>
                                <view class="mao">：</view>
                                <view class="content">{{ item.LOG_ADD_TIME }}</view>
                            </view>
                            <view class="info-item">
                                <view class="title">操作内容</view>
                                <view class="mao">：</view>
                                <view class="content">{{ item.LOG_CONTENT }}</view>
                            </view>
                            <view class="info-item">
                                <view class="title">IP地址</view>
                                <view class="mao">：</view>
                                <view class="content">{{ item.LOG_ADD_IP }}</view>
                            </view>
                        </view>
                    </view>
                </view>
                <!-- List END -->

                <!-- load begin -->

                <!-- parse <template is="listLoadTpl" :data="dataList, skin:'text-grey'"/> -->
                <block name="listLoadTpl" v-if="false">
                    <view v-if="!dataList || (dataList && dataList.page < dataList.count)" :class="'load text-grey loading ' + 'text-grey'"></view>
                    <view v-if="dataList && dataList.page > 1 && dataList.page == dataList.count" :class="'load text-grey over ' + 'text-grey'"></view>

                    <block v-if="noHintImg">
                        <image style="height: 500rpx" mode="aspectFit" v-if="dataList && dataList.total == 0" :src="noHintImg" />
                    </block>

                    <block v-else>
                        <view v-if="dataList && dataList.total == 0" :class="'load text-grey ' + 'text-grey'">{{ '暂无记录' ? '暂无记录' : '暂无记录哦~' }}</view>
                    </block>

                    <view style="height: 100rpx"></view>
                </block>
                <!-- load end -->
            </cmpt-comm-list>
        </block>
    </view>
</template>

<script>
const AdminBiz = require('../../../../biz/admin_biz.js');
const pageHelper = require('../../../../helper/page_helper.js');
export default {
    data() {
        return {
            isSuperAdmin: false,
            isAdmin: false,
            search: '',
            sortMenus: '',
            sortItems: '',

            dataList: {
                total: '',
                list: [],
                page: 0,
                count: 0
            },

            noHintImg: ''
        };
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad: function (options) {
        if (!AdminBiz.isAdmin(this)) {
            return;
        }

        //设置搜索菜单
        this.setData(this.getSearchMenuFun());
        this.setData({
            isSuperAdmin: AdminBiz.isSuperAdmin()
        });
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: async function () {},
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {},
    methods: {
        url: async function (e) {
            pageHelper.url(e, this);
        },

        bindCommListCmpt: function (e) {
            pageHelper.commListListener(this, e);
        },

        getSearchMenuFun: function () {
            let sortItems = [];
            let sortMenus = [
                {
                    label: '全部',
                    type: '',
                    value: ''
                },
                {
                    label: '系统',
                    type: 'type',
                    value: 99
                },
                {
                    label: '用户',
                    type: 'type',
                    value: 0
                },
                {
                    label: '内容/文章',
                    type: 'type',
                    value: 2
                },
                {
                    label: '预约/活动',
                    type: 'type',
                    value: 1
                }
            ];
            return {
                sortItems,
                sortMenus
            };
        }
    }
};
</script>
<style>
@import './admin_log_list.css';
@import 'undefined';
</style>
